package com.rowger.player.base

import android.os.Bundle
import android.os.PersistableBundle
import android.support.v7.app.AppCompatActivity
import com.rowger.player.ui.activity.MainActivity
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.debug
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast

/**
 * Created by luojie on 2018/4/14.
 * 所有activity的基类
override fun onCreate(saveIstanceState:Bundle?){
super.onCreate(savedInstanceState)
setContentView(getLayoutId())
initListener()
initData()
}
 */
abstract class BaseActivity:AppCompatActivity(),AnkoLogger {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        initLisenter()
        initData()
        debug { "2135" }
    }

    open protected fun initData() {

    }

    open protected fun initLisenter() {

    }

    abstract fun getLayoutId(): Int

    protected fun myToast(msg:String){
        runOnUiThread { toast(msg) }
    }
    //开启一个activity并且finish当前界面
    inline fun <reified T:BaseActivity>startActivityAndFinish(){
        startActivity<T>()
        finish()
    }


}